<!-- Horizontal Form -->
 <div class="box box-info">
      <!-- <div class="box-header with-border">
        <h3 class="box-title">添加参数</h3>
      </div>
      /.box-header -->
      <!-- form start -->
      <form class="form-horizontal">
        <div class="box-body">
          <div class="form-group">
            <label for="nameId" class="col-sm-2 control-label">参数名</label>

            <div class="col-sm-10">
              <input type="text" class="form-control" name="name" id="nameId" placeholder="名称">
            </div>
          </div>
           <div class="form-group">
            <label for="valueId" class="col-sm-2 control-label">参数值</label>
            <div class="col-sm-10">
              <input type="text" class="form-control" name="name" id="valueId" placeholder="名称">
            </div>
          </div>
          <div class="form-group">
            <label for="noteId" class="col-sm-2 control-label">描述</label>

            <div class="col-sm-10">
              <input type="text" class="form-control" name="note" id="noteId" placeholder="描述">
            </div>
          </div>
        </div>
        <!-- /.box-body -->
        <div class="box-footer">
        <!--   <button type="button" class="btn btn-default btn-cancel">Cancel</button>
          <button type="button" class="btn btn-info pull-right btn-save">Save</button> -->
        </div>
        <!-- /.box-footer -->
      </form>
    </div>
    <script type="text/javascript">
  		$(function(){
  			//模态框的保存按钮上注册click事件
  			$("#myModal").on("click",".btn-save",doSaveOrUpdate);
  			$('#myModal').on('hidden.bs.modal', function () {
  				$("#myModal").off("click");
  				$("#myModal").removeData();
  			})
  			var rowData = $("#myModal").data("rowData");
  			console.log(rowData);
  			//假如模态框上有绑定数据,通过此数据初始化页面显示数据
  			if(rowData)
  				doInitEditFormData(rowData);
  		})
  		//初始化表单数据
  		function doInitEditFormData(rowData){
  			$("#nameId").val(rowData.name);
  			$("#valueId").val(rowData.value);
  			$("#noteId").val(rowData.note);
  		}
  		function doSaveOrUpdate(){
  			var params=doGetEditFormData();
  			var rowData=$("#myModal").data("rowData");
  			if(rowData)
  				params.id=rowData.id;
  			var updateUrl="config/doUpdateObject.do";
  			var insertUrl="config/doSaveObject.do";
  			var url=rowData?updateUrl:insertUrl;
  			$.post(url,params,function(result){
  				if(result.state==1){
  					alert(result.message);
  					doGetObjects();
  					$("#myModal").modal("hide");
  				}else{
  					alert(result.message);
  				}
  			})
  		}
  		function doGetEditFormData(){
  			var params={
  				name:$("#nameId").val(),
  				value:$("#valueId").val(),
  				note:$("#noteId").val()
  			}
  			return params;
  		}
    </script>
    
    
    
    
    
    
    
    